package table_Mixage;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *  Import Raw
 *
 *
 * @author Damien Deldon</a>
 * @version 1.0
 */

public class ImportRaw extends JDialog implements ActionListener {
	
	private static final long serialVersionUID = -2591595044813521464L;
	JTextField can;
	JTextField frequ;
	JTextField res;
	
	public ImportRaw(JFrame parent, String titre, String message) {
		super(parent,titre,true);
		if (parent != null) {
			Dimension parentSize = parent.getSize(); 
			Point p = parent.getLocation();
			setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
			setResizable(false);
			
		}
		
		//Ajout du message
		JPanel titrePane = new JPanel();
		titrePane.add(new JLabel(message));
		//setContentPane(titrePane);
		
		JPanel optionsPane = new JPanel(new GridLayout(3,2));
		
		//Saisie Nombre Canaux
		can = new JTextField("");
		can.setColumns(7);
			
		//Saisie Fréquence
		frequ = new JTextField("");
		frequ.setColumns(7);
			
		//Saisie Résolution
		res = new JTextField("");
		res.setColumns(7);
		
		//Ajout des composants	
		optionsPane.add(new JLabel("Nombres Cannaux : "));
		optionsPane.add(can);
		optionsPane.add(new JLabel("Fréquence : "));
		optionsPane.add(frequ);
		optionsPane.add(new JLabel("Résolution : "));
		optionsPane.add(res);
		
		//Ajout Bouton OK
		JPanel boutonPane = new JPanel();
		JButton bouton = new JButton("OK");
		bouton.addActionListener(this);
		boutonPane.add(bouton);
		
		JPanel importerPane = new JPanel(new BorderLayout());
		importerPane.add(titrePane, BorderLayout.NORTH);
		importerPane.add(optionsPane, BorderLayout.CENTER);
		importerPane.add(boutonPane, BorderLayout.SOUTH);
		
		getContentPane().add(importerPane);
		
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		pack(); 
		setVisible(true);
		
		
	}
		public void actionPerformed(ActionEvent e) {
			if (can.getText().equals("") || frequ.getText().equals("") || res.getText().equals("")){
			}else{
				PlayerPiste.importerNbCanaux = Integer.parseInt(can.getText());
				PlayerPiste.importerFrequence = Integer.parseInt(frequ.getText());
				PlayerPiste.importerResolution = Integer.parseInt(res.getText());
				setVisible(false);
				dispose();
			}
	}
}
